package com.hu.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 响应码枚举
 * @author 355760
 */
public enum MessageEnum {
    SUCCESS(200, "操作成功"),
    WARNING(201, "警告"),
    FAIL(500, "请求失败"),

    EXCEPTION(9999, "服务器异常"),
    UNZIP_FAIL(9998, "解压zip文件失败"),
    IO_EXCEPTION(9997, "IO异常"),
    NoSuchFileException(9996, "文件未找到"),

    USER_ACCOUNT_EMPTY(1002, "账号不能为空"),
    USER_PASSWORD_EMPTY(1003, "密码不能为空"),
    USER_NOT_EXIST(1004, "用户不存在"),
    HEADER_TOKEN_EMPTY(1005, "token请求头缺失"),
    USER_NAME_EMPTY(1006, "用户名为不能为空"),
    ROLE_ID_EMPTY(1008, "角色id不能为空"),
    RELEVANCE_TYPE_EMPTY(1009, "关系类型不能为空"),
    SECOND_IDS_EMPTY(1010, "secIds集合不能为空"),
    URL_EMPTY(1011, "url不能为空"),
    MODULE_NAME_EMPTY(1016, "模块名称不能为空"),
    SORT_NO_EMPTY(1017, "排序号不能为空"),
    IS_LEAF_EMPTY(1018, "是否叶子节点不能为空"),
    CODE_EMPTY(1019, "标识不能为空"),
    ICON_NAME_EMPTY(1021, "图标名称不能为空"),
    ID_EMPTY(1022, "id不能为空"),
    LABEL_TEMPLATE_TYPE_EMPTY(1023, "标签模板类型不能为空"),
    LABEL_TEMPLATE_NAME_EMPTY(1024, "标签模板名称不能为空"),
    LABEL_NAME_EMPTY(1025, "标签英文名称不能为空"),
    LABEL_NAME_C_EMPTY(1026, "标签中文名称不能为空"),
    LABEL_VALUE_TYPE_EMPTY(1027, "标签数值类型不能为空"),
    LABEL_INIT_VALUE_EMPTY(1028, "标签初始值不能为空"),
    CATEGORY_LIB_NAME_EMPTY(1028, "分类规则库名称不能为空"),
    CATEGORY_LIB_ID_EMPTY(1029, "分类规则库ID不能为空"),
    CATEGORY_NAME_EMPTY(1030, "分类规则名称不能为空"),
    PARENT_ID_EMPTY(1031, "父节点ID不能为空"),
    CATEGORY_ID_EMPTY(1031, "分类规则ID不能为空"),
    LABEL_TEMPLATE_ID_EMPTY(1032, "标签模板ID不能为空"),
    LABEL_INFO_EMPTY(1034, "标签信息不能为空"),
    START_TIME_EMPTY(1035, "起始时间不能为空"),
    END_TIME_EMPTY(1036, "结束时间不能为空"),
    GROUP_TYPE_EMPTY(1037, "分组类型不能为空"),
    CASECADE_ID_EMPTY(1038, "级别编码不能为空"),
    LABEL_TYPE_EMPTY(1039, "标签类型不能为空"),
    TS_EMPTY(1040, "时间戳不能为空"),
    SECURITY_CODE_EMPTY(1041, "校验码不能为空"),
    FILE_EMPTY(1042, "文件不能为空"),
    FILE_TYPE_EMPTY(1043, "文件类型不能为空"),
    SCENE_STATUS_EMPTY(1044, "场景状态不能为空"),
    SCENE_ID_EMPTY(1045, "场景Id不能为空"),
    SCENE_FILE_NOT_EXIST(1046, "场景文件不存在"),
    FILE_NOT_EXIST(1047, "文件不存在"),
    USER_ID_EMPTY(1048, "用户Id不能为空"),
    LABEL_ID_EMPTY(1049, "标签Id不能为空"),
    RESOURCES_EMPTY(1050, "资源集合不能为空"),
    RESOURCES_ID_EMPTY(1051, "资源Id不能为空"),
    RESOURCES_TYPE_EMPTY(1052, "资源类型不能为空"),
    DYNAMIC_ENTITY_LABEL_NOT_EXIST(1053, "动态实体标签不存在"),
    SCENE_LABEL_TREE_NOT_EXIST(1054, "标签树信息不存在"),
    SCENE_LABEL_ID_TREE_EMPTY(1055, "标签树Id不能为空"),
    EXTEND_FIELD_EMPTY(1056, "拓展字段不能为空"),
    SCENE_LABEL_TREE_LABELS_NOT_EXIST(1057, "标签树内标签信息不存在"),
    CATEGORY_TAG_EMPTY(1058, "分类标识不能为空"),

    USER_TOKEN_NOT_EXPIRED(2001, "token过期，请重新登录"),
    ORG_NOT_EXIST(2002, "组织信息不存在"),
    USER_ACCOUNT_PASSWORD_INVALID(2004, "账号或密码错误"),
    ROLE_NOT_EXIST(2007, "角色信息不存在"),
    URL_INVALID(2008, "url不合法"),
    LABEL_TEMPLATE_NOT_EXIST(2009, "标签模板信息不存在"),
    LABEL_TEMPLATE_TYPE_INVALID(2010, "标签模板类型无效"),
    LABEL_VALUE_TYPE_INVALID(2011, "标签数值类型无效"),
    CATEGORY_LIB_NOT_EXIST(2012, "分类规则库信息不存在"),
    LABEL_TYPE_INVALID(2013, "标签类型无效,标签id=%s"),
    CATEGORY_NOT_EXIST(2014, "分类规则数据不存在"),
    START_TIME_INVALID(2015, "起始时间无效"),
    END_TIME_INVALID(2016, "结束时间无效"),
    GROUP_TYPE_INVALID(2017, "分组类型无效"),
    TIMESTAMP_INVALID(2018, "结束时间不能早于起始时间"),
    SCENE_STATUS_INVALID(2019, "场景状态类型无效"),
    LABEL_TYPE_INVALID_NO_ARG(2020, "标签类型无效"),
    TS_INVALID(2021, "时间戳无效"),
    SECURITY_CODE_INVALID(2022, "安全码无效"),
    FILE_SIZE_TOO_SMALL_EMPTY(2023, "文件:%s 过小"),
    FILE_SIZE_TOO_LARGE_EMPTY(2024, "文件:%s 超出%sM"),
    FILE_TYPE_INVALID(2025, "文件:%s 类型不支持, 可用文件类型:%s"),
    SCENE_NOT_EXIST(2026, "场景信息不存在"),
    SCENE_FILE_PARSE_FAIL_MSG(2027, "场景文件解析失败: %s"),
    LABEL_ENTITY_NOT_EXIST(2028, "标签实体不存在"),
    LABEL_VALUE_TYPE_MISMATCH(2029, "标签初始数值值与数值类型不符"),
    RESOURCES_TYPE_INVALID(2030, "资源类型无效"),
    EXTEND_FIELD_INVALID(2031, "拓展字段类型无效"),
    FORMAT_FILE_NOT_EXIST(2032, "%s 文件不存在"),
    LICENSE_INVALID(2033, "license无效"),

    USER_STATUS_EXCEPTION(3000, "账号状态异常，可能已停用"),
    PARENT_NOT_EXISTS(3001, "父节点不存在"),
    USER_ROLE_RELEVANCE_EXCEPTION(3005, "账户角色关系异常"),
    ROLE_INFO_EXCEPTION(3006, "角色信息异常"),
    ADMIN_MODIFY_EXCEPTION(3007, "不能修改管理员账号"),
    LABEL_TEMPLATE_MODIFY_EXCEPTION(3008, "不能修改系统预定标签模板"),
    MAX_TIMESTAMP_EXCEPTION(3009, "时间跨度不能超过%s天"),
    SCENE_FILE_PARSE_FAIL(3010, "场景文件解析失败"),
    MODIFY_PARAM_EMPTY(3011, "数据更新内容不能为空"),
    SCENE_FILE_PARSE_EMPTY(3012, "场景文件解析内容为空"),
    OTHER_USER_PROCESSING(3014, "其他用户正在执行该操作，请稍后"),
    USER_ORG_RELEVANCE_EXCEPTION(3015, "账户组织关系异常"),
    RESOURCE_NOT_EXISTS(3016, "访问的资源不存在"),


    METHOD_NOT_SUPPORTED(4000, "不支持的请求方式"),
    REQUEST_BODY_INVALID(4001, "请求body无效"),
    CONTENT_TYPE_NOT_SUPPORTED(4002, "不支持的content-type"),
    AUTH_FOUNDATION(4003, "暂无权限"),
    ARGS_INVALID(4004, "请求参数缺失"),
    NON_EXISTENT(4005, "请求参数无效"),

    REMOTE_CALL_FAIL(5000, "调用其他服务异常"),

    ORG_NAME_PARAM_EMPTY(5001, "组织名称参数不为空"),
    ORG_NAME_REPEAT(5001, "组织名称重复"),
    ORG_ID_PARAM_EMPTY(5002, "组织ID参数不为空"),
    ORG_STATUS_PARAM_EMPTY(5003, "组织状态不为空"),
    ORG_ON_UPDATE_TO_CHILD(5004, "当前组织不能变更到子层级"),
    PARENT_NOT_EXIST(5005, "父级信息不存在"),

    MODULE_ID_PARAM_EMPTY(5006, "模块ID参数不为空"),
    MODULE_NOT_EXIST(5007, "模块不存在"),
    PARENT_INVALID(5008, "父级无效"),

    ROLE_NAME_EMPTY(5009, "角色名称不能为空"),
    ROLE_STATUS_EMPTY(5010, "角色状态不能为空"),

    PAG_ENUM_STATUS_EMPTY(5011, "分页参数不能为空"),
    PAGE_SIZE_STATUS_EMPTY(5012, "每页数量不能为空"),

    MODULE_ID_EMPTY(5013, "模块ID为空"),

    MODULE_ELEMENT_NAME_EMPTY(5014, "菜单名称不能为空"),
    MODULE_ELEMENT_DOM_ID_EMPTY(5015, "菜单DOM ID不能为空"),
    MODULE_ELEMENT_ICON_EMPTY(5016, "菜单图标不能为空"),
    MODULE_ELEMENT_CLASS_EMPTY(5017, "菜单样式不能为空"),
    MODULE_ELEMENT_MODULE_ID_EMPTY(5018, "菜单所属模块Id不能为空"),
    MODULE_ELEMENT_ID_EMPTY(5019, "菜单Id不能为空"),

    ADMIN_FOUNDATION(5020, "不能更改管理员信息"),
    MODULE_ON_UPDATE_TO_CHILD(5004, "当前模块不能变更到子层级"),
    CUSTOM_LABEL_NON_EXISTENT(5003, "自定义模板不存在"),
    GROUP_CONDITION(5005, "分组条件不能为空"),
    ON_UPDATE_TO_CHILD(5006, "当前层级不能变更到子层级"),
    ON_UPDATE_TO_PARENT_LEVEL(5007, "当前层级不能变更到父层级"),
    SCENE_TAGS_NOT_IMPORT(5008, "场景标签暂不支持导入"),
    ODD_TAGS_NOT_IMPORT(5009, "ODD标签暂不支持导入"),
    SOTIF_TAGS_NOT_IMPORT(5010, "SOTIF标签暂不支持导入"),
    LABEL_NOT_SUPPORT(5011,"该类场景不支持标签功能"),
    ;

    private final Integer code;
    private final String message;

    MessageEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private static final Map<Integer, MessageEnum> MAPPING = new HashMap<>();

    static {
        for (MessageEnum entity : values()) {
            MAPPING.put(entity.code, entity);
        }
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static MessageEnum GET_ENUM_BY_CODE(Integer code) {
        return MAPPING.get(code);
    }

    public static Map<Integer, MessageEnum> GET_ENUM_MAP() {
        return MAPPING;
    }
}
